<template>
	<view class="container">
		<view class="nei">
			<uni-easyinput placeholder="请输入验证码" prefixIcon="email" maxlength="11" v-model="from.username"></uni-easyinput>
			<uni-countdown :show-day="false" :hour="false" :minute="false" :second="59"></uni-countdown>
			<!-- <button>获取验证码</button> -->
			<!-- <input type="text" v-model="username" placeholder="请输入验证码" /> -->
		</view>
		<view class="nei">
			<uni-easyinput placeholder="请输入用户名" prefixIcon="person" maxlength="11"
				v-model="from.password"></uni-easyinput>
			<!-- <input type="text" v-model="password" placeholder="请输入用户名" /> -->
		</view>
		<view class="nei">
			<!-- <input type="text" v-model="mobile" placeholder="请输入密码" /> -->
			<uni-easyinput placeholder="请输入密码" prefixIcon="locked" maxlength="11" v-model="from.mobile"></uni-easyinput>
		</view>
		<view class="nei">
			<!-- <input type="text" v-model="code" placeholder="请再次确认密码" /> -->
			<uni-easyinput placeholder="请再次确认密码" prefixIcon="locked" maxlength="11" v-model="from.code"></uni-easyinput>
		</view>
		<button class="zhu" @click="zhu">注册</button>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				username: '',
				password: '',
				mobile: '',
				code: '',
				from: {}
			}
		},
		// 刷新方法
		onLoad(obj) {
			console.log(obj.mobile)
			this.from.mobile = obj.mobile
		},
		methods: {

			zhu() {
				console.log(this.from)
				uni.request({
					url: 'http://47.91.230.137:8086/wx/auth/register',
					method: "POST",
					data: this.from,
					success: (res) => {
						console.log(res)
						const data = res.data
						// debugger
						if (data.errno == 0) {
							uni.showToast({
								title: '注册成功',
							})
							// 跳转页面
							setTimeout(() => {
								uni.navigateTo({
									url: '/pages/denglu/denglu'
								})
							}, 1000)
							// 存储用户的数据到 token
							uni.setStorageSync('user', data.data.token)
						} else {
							uni.showToast({
								icon: 'none',
								title: data.errmsg
							})
						}
					}
				})
				// this.$api.post("/wx/auth/register", {
				// 	username: this.username,
				// 	password: this.password,
				// 	mobile: this.mobile,
				// 	code: this.code
				// }).then(res => {
				// 	this.$ui.showSuccess("注册成功")
				// 	// debugger
				// 	uni.setStorageSync('userInfo', res.data.token)
				// 	}),
				// 	uni.navigateTo({
				// 		url:'/pages/zhuce/regie1'
				// })
			}
		},
	}
</script>

<style>
	.nei {
		width: 600rpx;
		margin: 0 auto;
		margin-top: 10rpx;
		margin-bottom: 10rpx;
	}

	.zhu {
		/* display: flex;
		justify-content: center; */
		background-color: lightgreen;
		margin: 0 auto;
		border-radius: 40rpx;
	}

	/* @import url("./styles.css"); */
</style>